var e = require("../../../../@babel/runtime/helpers/interopRequireWildcard").default,
  t = require("../../../../@babel/runtime/helpers/interopRequireDefault").default,
  a = require("../../../../@babel/runtime/helpers/defineProperty"),
  r = require("../../../../@babel/runtime/helpers/objectSpread2"),
  i = require("../../../../@babel/runtime/helpers/slicedToArray"),
  s = require("../../../../@babel/runtime/helpers/regeneratorRuntime"),
  n = require("../../../../@babel/runtime/helpers/asyncToGenerator"),
  o = t(require("../../../../lib/dayjs/index")),
  u = e(require("./utils"));
Page({
  useStore: function (e) {
    return {
      customerServicePhone: e.global.customerServicePhone,
      userInfo: e.user.userInfo
    }
  },
  data: {
    pageOptions: {
      title: "我的银行卡"
    },
    filterParams: {
      add_type: "",
      sub_type: "",
      month: u.subtractMonth(),
      sid: "0",
      aid: "0"
    },
    isShowFilter: !1,
    totalIntegral: 1e3,
    isShowRecordList: !0,
    recordList: [],
    isInitLoad: !1,
    datePickerValue: u.subtractMonth(),
    filterOptions: {
      sub_type_list: [],
      add_type_list: []
    },
    minTime: u.subtractMonth(2),
    maxTime: u.subtractMonth(),
    list: [],
    pageNum: 1
  },
  onLoad: function (options) {
    if (options.type) {
      this.setData({
        type: options.type
      })
    }
    this.getBankList()
  },
  onShow() {},
  bankDetail(e) {
    if (this.data.type) {
      var pages = getCurrentPages() //获取加载的页面
      var prePage = pages[pages.length - 2] //获取当前页面的对象
      console.log(e)
      prePage.setData({
        bankAccount: e.currentTarget.dataset.bankaccount,
        bankCode: e.currentTarget.dataset.bankcode,
        bankNo: e.currentTarget.dataset.bankno,
        id: e.currentTarget.dataset.id
      })
      wx.navigateBack()
      return false
    }
    var id = e.currentTarget.dataset.id
    wx.navigateTo({
      url: '/subpackage/personal/integral/addbank/index?bankId=' + id,
    })
  },
  getBankList() {
    wx.showLoading({
      title: '加载中...',
    })
    $.request['GET/business/bankCard/pageList']({
      pageNum: this.data.pageNum,
      pageSize: 10
    }).then(res => {
      res = res[0]
      if (res.code === 20002) {
        this.setData({
          pageNum: this.data.pageNum + 1,
          list: res.data.data
        })
      }
    }).finally(() => {
      wx.hideLoading()
    })
  },
  addbank() {
    wx.navigateTo({
      url: '/subpackage/personal/integral/addbank/index',
    })
  },
  switchFilterPopupVisible: function () {
    this.setData({
      isShowFilter: !this.data.isShowFilter
    })
  },
  closeFilterPopup: function () {
    this.setData({
      isShowFilter: !1
    })
  },

  resetData: function () {
    this.setData({
      "filterParams.sid": 0,
      "filterParams.aid": 0,
      recordList: []
    })
  },
  onChangeDate: function (e) {

  },
  onFilter: function (e) {

  },
  getFilterConf: function () {
    var e = this;
    return n(s().mark((function t() {
      var a, r, n;
      return s().wrap((function (t) {
        for (;;) switch (t.prev = t.next) {
          case 0:
            return t.next = 2, $.request["GET/v2/coin/conf"]();
          case 2:
            a = t.sent, r = i(a, 1), n = r[0], e.setData({
              filterOptions: null == n ? void 0 : n.content
            });
          case 6:
          case "end":
            return t.stop()
        }
      }), t)
    })))()
  },
  onClickDetail: function (e) {
    var t = e.detail,
      a = t.detail,
      r = t.type,
      i = t.info_id;
    1 == (null == a ? void 0 : a.is_deleted) ? $.msg("该信息已经删除") : 1 == (null == a ? void 0 : a.is_forbidden) ? $.msg("该信息被投诉过多，无法进行查看") : 1 == (null == a ? void 0 : a.is_company) ? $.router.push("/subpackage/supplier/supplier-detail/index", {
      id: i
    }) : $.router.push("/subpackage/common/details/index", {
      uuid: i,
      mode: 10 == r ? 5 : r
    })
  },
  onReachBottom: function () {

  },
  onPullDownRefresh: function () {
    var e = this.data.datePickerValue;
    e !== (0, o.default)().format("YYYY-MM") && (e = (0, o.default)(e).add(1, "month").format("YYYY-MM"));
    var t = {
      detail: {
        value: e
      }
    };
    this.onChangeDate(t)
  }
});